< previous page page_513 next page >

Page 513
Changing the SQL Server tables accessed by the new application may require changing the application code, which will be difficult after the consultant is long gone.
An easy answer to these problems is to build an export file on an automated basis for the new program to use. An Access database is an ideal format for this export file because the program can use it just as it would the SQL Server.
Building the Sample Program
In case you have not noticed, I like to rely on INI files a lot. There's a reason for this: They can make your program more useful. This result should be especially apparent in this example because the INI file contains all the information the program needs to perform the export operation. You can compile the program once and use several INI files for different exports. It is intended to be a command-line utility and is executed like this:
MDBMAKE C:\Data\REVENUE.INI
MDBMAKE C:\Data\Employee.INI
The INI files themselves contain information that the program needs to connect to the SQL Server and create the Access tables. For example, entries specify the Access database (destination database) and the SQL Server connect string (source database):
DBFile=\\MYSERVER\PUBLIC\HRDATA\HRDATA.MDB
SQLConnect="ODBC:DATABASE=personnel:uid=fred:pwd=garvin:DSN=MYSQLDB"
Next, the [Tables] section specifies the name and number of tables you want to create:
[Tables]
Tables=4
Table1SQL=hrinfo
Table1MDB=hrinfo
Table1INI=hrinfo
Each table also contains a section that specifies the number and type of the fields in the table. For example, the hrinfo section might look like this:
[hrinfo]
Fields=2
Fd1Name="EmployeeID"
Fd1Type=DOUBLE
Fd2Name="Name"
Fd2Type=TEXT
Fd2Size=40
While executing, the program uses For loops to browse through each section in the INI file as it needs the field information. For example, the hrinfo table created by the program has two fields: EmployeeID, which is of type Double, and Name, which is a 40-character text field.
Understanding the Sample Program
The SQL export program has just a few generic functions and no real user interface (other than a progress screen). The important functions are as follows:

 
< previous page page_513 next page >